//
//  STNewFunctionVC.swift
//  Demo-04-TabBarTest
//
//  Created by 苏统世 on 16/5/13.
//  Copyright © 2016年 SuTon. All rights reserved.
//

import UIKit

let imageCount = 4

class STNewFunctionVC: UIViewController {
    
    let basicView = STNewFunctionView()
    
    var index:CGFloat = 0{
        didSet{
            if index == CGFloat(imageCount-1){
                basicView.startAnimation()
            }else if(index<(CGFloat(imageCount-2)+0.3)){
                basicView.hiddenStartButton()
            }
        }
    }
    
    override func loadView() {
        basicView.scrollView.delegate=self
        view = basicView
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor=UIColor.lightGrayColor()
    }
}

extension STNewFunctionVC:UIScrollViewDelegate{
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        //只要往回滑一点，index = 2 ，按钮就隐藏,问题已解决
        index = scrollView.contentOffset.x/scrollView.frame.width
    }
    /// scrollView停止滚动
    func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
        
//        let offsetX = Int(scrollView.contentOffset.x / scrollView.frame.width)
//
//        STPrint(items: "\(offsetX)")
//        
//        if offsetX==imageCount-1 {
//            basicView.startAnimation()
//        }else{
//            basicView.hiddenStartButton()
//        }
    }
}


